// 蜂窝蜜造平台生成代码，如手工更改，请添加到 .beeignore 忽略生成
package com.fowo.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.IdListPo;
import com.fowo.api.common.model.IdPo;
import com.fowo.api.common.model.ImportRow;
import com.fowo.api.common.model.OptionItem;
import com.fowo.api.common.model.R;
import com.fowo.api.common.util.ResponseUtils;
import com.fowo.api.entity.AdjustmentOrder;
import com.fowo.api.model.adjustment.order.AdjustmentOrderDataFiltrationParam;
import com.fowo.api.model.adjustment.order.AdjustmentOrderDataFiltrationResult;
import com.fowo.api.model.adjustment.order.AdjustmentOrderImportPo;
import com.fowo.api.model.adjustment.order.AdjustmentOrderItemVo;
import com.fowo.api.model.adjustment.order.AdjustmentOrderSearchParamPo;
import com.fowo.api.model.adjustment.order.AdjustmentOrderVo;
import com.fowo.api.service.AdjustmentOrderService;
import com.fowo.api.sys.entity.SysFile;
import com.fowo.api.user.model.JwtUserInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StreamUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "调整单")
@RequestMapping("/api/adjustment-order")
@RestController
public class AdjustmentOrderController {

  @Resource
  private AdjustmentOrderService service;

  @Operation(summary = "查询结果")
  @GetMapping
  public R<List<AdjustmentOrderItemVo>> search(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.search(search));
  }

  @Operation(summary = "快速查询选项(有缓存)")
  @GetMapping("options")
  public R<List<OptionItem<AdjustmentOrderItemVo>>> searchOptions(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.searchOptions(search));
  }

  @Operation(summary = "查询最后更新时间")
  @GetMapping("lastUpdateTime")
  public R<Date> searchLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.searchLastUpdateTime(search));
  }

  @Operation(summary = "获取分页查询结果")
  @GetMapping("page")
  public R<Page<AdjustmentOrderItemVo>> getPage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageSearch(search));
  }

  @Operation(summary = "获取包括子表的查询结果")
  @GetMapping("page-with-child")
  public R<Page<?>> getPageWithChild(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageWithChildSearch(search));
  }

  @Operation(summary = "仅获取子表的查询结果")
  @GetMapping("page-only-child/{parentId}")
  public R<Page<?>> getPageOnlyChild(
    @PathVariable Long parentId,
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageOnlyChildSearch(parentId, search));
  }

  @Operation(summary = "查询是否后台下载")
  @GetMapping("getBackgroundExportFlag")
  public R<Boolean> getBackgroundExportFlag(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.getBackgroundExportFlag(search));
  }

  @Operation(summary = "获取详情")
  @GetMapping("{id}")
  public R<AdjustmentOrderVo> getVoById(@PathVariable Long id) {
    return R.data(() -> service.getVoById(id));
  }

  @Operation(summary = "获取调整单号相关的编号列表")
  @GetMapping("order-sn/{texts}/ids")
  public R<List<Long>> getIdsByOrderSn(@PathVariable String texts) {
    List<String> nameList = Arrays
      .stream(texts.split(","))
      .collect(Collectors.toList());
    return R.data(() -> service.getIdsByOrderSn(nameList));
  }

  @Operation(summary = "获取编号相关的调整单号列表")
  @GetMapping("order-sn/{ids}")
  public R<List<String>> getVoById(@PathVariable String ids) {
    List<Long> idList = Arrays
      .asList(ids.split(","))
      .stream()
      .map(Long::valueOf)
      .collect(Collectors.toList());
    return R.data(() -> service.getOrderSnByIds(idList));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderCreate')")
  @Operation(summary = "新增")
  @PostMapping
  public R<Long> create(@Validated @RequestBody AdjustmentOrderVo model) {
    return R.data(() -> service.create(model));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderEdit')")
  @Operation(summary = "更新")
  @PutMapping
  public R update(@RequestBody AdjustmentOrderVo model) {
    return R.run(() -> service.update(model));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderEdit')")
  @Operation(summary = "编辑更新")
  @PutMapping("edit")
  public R updateForEdit(@RequestBody AdjustmentOrderVo model) {
    return R.run(() -> service.updateForEdit(model));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderDelete')")
  @Operation(summary = "删除")
  @DeleteMapping("{id}")
  public R delete(@PathVariable Long id) {
    return R.run(() -> service.delete(id));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderDelete')")
  @Operation(summary = "批量删除")
  @DeleteMapping("batch")
  public R batchDelete(@RequestBody IdListPo po) {
    return R.run(() -> service.batchDelete(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderImport')")
  @Operation(summary = "导入预览")
  @PostMapping("import-preview")
  public R<List<ImportRow<AdjustmentOrderImportPo>>> importPreview(
    @RequestBody SysFile sysFile,
    @RequestParam(name = "template", required = false) Long templateId,
    @RequestParam(
      name = "allowOverrides",
      defaultValue = "false"
    ) boolean allowOverrides
  ) {
    return R.data(() ->
      service.importPreview(sysFile, templateId, allowOverrides)
    );
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderImport')")
  @Operation(summary = "完成导入")
  @PostMapping("import-done")
  public R importDone(
    @RequestBody List<ImportRow<AdjustmentOrderImportPo>> rows,
    @RequestParam(name = "template", required = false) Long templateId
  ) {
    return R.run(() -> service.importDone(rows, templateId));
  }

  @Operation(summary = "下载导入模版")
  @GetMapping("import/template")
  public void downloadImportTemplate(HttpServletResponse response)
    throws IOException {
    ResponseUtils.setAttachmentFileName(response, "调整单导入模版.xlsx");
    InputStream inputStream = new ClassPathResource(
      "templates/AdjustmentOrder.xlsx"
    )
      .getInputStream();
    StreamUtils.copy(inputStream, response.getOutputStream());
  }

  @Operation(summary = "导出")
  @GetMapping("export")
  @PreAuthorize("@am.canAccess('adjustmentOrderExport')")
  public void export(
    @RequestParam(name = "template", required = false) Long templateId,
    AdjustmentOrderSearchParamPo search,
    HttpServletResponse response
  ) throws Exception {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    service.export(templateId, search, response);
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderAcknowledgeAdjustment')")
  @Operation(summary = "确认调整")
  @PostMapping("acknowledgeAdjustment")
  public R acknowledgeAdjustment(@RequestBody IdPo po) {
    return R.run(() -> service.acknowledgeAdjustment(po.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderLockpInventory')")
  @Operation(summary = "锁库存_仓位")
  @PostMapping("lockpInventory")
  public R lockpInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.lockpInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderCancelLockpInventory')")
  @Operation(summary = "取消锁库存_仓位")
  @PostMapping("cancelLockpInventory")
  public R cancelLockpInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.cancelLockpInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderLockStockOut')")
  @Operation(summary = "出库锁定")
  @PostMapping("lockStockOut")
  public R lockStockOut(@RequestBody IdPo idPo) {
    return R.run(() -> service.lockStockOut(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderLocksInventory')")
  @Operation(summary = "锁库存_即时")
  @PostMapping("locksInventory")
  public R locksInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.locksInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderCancelLocksInventory')")
  @Operation(summary = "取消锁库存_即时")
  @PostMapping("cancelLocksInventory")
  public R cancelLocksInventory(@RequestBody IdPo idPo) {
    return R.run(() -> service.cancelLocksInventory(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderSyncData')")
  @Operation(summary = "同步数据")
  @PostMapping("syncData")
  public R syncData() {
    return R.run(() -> service.syncData());
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderBatchValidationAdjustment')")
  @Operation(summary = "批量确认调整")
  @PostMapping("batchValidationAdjustment")
  public R batchValidationAdjustment(@RequestBody IdListPo po) {
    return R.run(() -> service.batchValidationAdjustment(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderRevocation')")
  @Operation(summary = "撤销")
  @PostMapping("revocation")
  public R revocation(@RequestBody IdPo po) {
    return R.run(() -> service.revocation(po.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderGood')")
  @Operation(summary = "正常库存")
  @PostMapping("good")
  public R good(@RequestBody IdPo idPo) {
    return R.run(() -> service.good(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderBad')")
  @Operation(summary = "次品库存")
  @PostMapping("bad")
  public R bad(@RequestBody IdPo idPo) {
    return R.run(() -> service.bad(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderStockOut')")
  @Operation(summary = "出库")
  @PostMapping("stockOut")
  public R stockOut(@RequestBody IdPo idPo) {
    return R.run(() -> service.stockOut(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderStockIn')")
  @Operation(summary = "入库")
  @PostMapping("stockIn")
  public R stockIn(@RequestBody IdPo idPo) {
    return R.run(() -> service.stockIn(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderUnGood')")
  @Operation(summary = "撤销正常入库")
  @PostMapping("unGood")
  public R unGood(@RequestBody IdPo idPo) {
    return R.run(() -> service.unGood(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderUnBad')")
  @Operation(summary = "撤销次品库存")
  @PostMapping("unBad")
  public R unBad(@RequestBody IdPo idPo) {
    return R.run(() -> service.unBad(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderUnStockOut')")
  @Operation(summary = "撤销出库")
  @PostMapping("unStockOut")
  public R unStockOut(@RequestBody IdPo idPo) {
    return R.run(() -> service.unStockOut(idPo.getId()));
  }

  @PreAuthorize("@am.canAccess('adjustmentOrderUnStockIn')")
  @Operation(summary = "撤销入库")
  @PostMapping("unStockIn")
  public R unStockIn(@RequestBody IdPo idPo) {
    return R.run(() -> service.unStockIn(idPo.getId()));
  }

  /**
   * 视图选项卡标题上显示计数
   */
  @Operation(summary = "视图选项卡标题上显示计数")
  @GetMapping("getTabHeaderShowTotal")
  public R<Map> getTabHeaderShowTotal() {
    return R.data(() -> service.getTabHeaderShowTotal());
  }

  @Operation(summary = "全部")
  @GetMapping("vad-all")
  public R<List<AdjustmentOrderItemVo>> vadAll(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadAll(search));
  }

  @Operation(summary = "全部分页")
  @GetMapping("vad-allPage")
  public R<Page<AdjustmentOrderItemVo>> vadAllPage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadAllPage(search));
  }

  @Operation(summary = "全部包括子表的查询结果")
  @GetMapping("vad-allPage-with-child")
  public R<Page<?>> vadAllPageWithChild(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.vadAllPageWithChildSearch(search));
  }

  @Operation(summary = "全部最后更新时间")
  @GetMapping("vad-allLastUpdateTime")
  public R<Date> vadAllLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadAllLastUpdateTime(search));
  }

  @Operation(summary = "待提交")
  @GetMapping("vad-submit")
  public R<List<AdjustmentOrderItemVo>> vadSubmit(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadSubmit(search));
  }

  @Operation(summary = "待提交分页")
  @GetMapping("vad-submitPage")
  public R<Page<AdjustmentOrderItemVo>> vadSubmitPage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadSubmitPage(search));
  }

  @Operation(summary = "待提交包括子表的查询结果")
  @GetMapping("vad-submitPage-with-child")
  public R<Page<?>> vadSubmitPageWithChild(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.vadSubmitPageWithChildSearch(search));
  }

  @Operation(summary = "待提交最后更新时间")
  @GetMapping("vad-submitLastUpdateTime")
  public R<Date> vadSubmitLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadSubmitLastUpdateTime(search));
  }

  @Operation(summary = "待审批")
  @GetMapping("vad-approve")
  public R<List<AdjustmentOrderItemVo>> vadApprove(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadApprove(search));
  }

  @Operation(summary = "待审批分页")
  @GetMapping("vad-approvePage")
  public R<Page<AdjustmentOrderItemVo>> vadApprovePage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadApprovePage(search));
  }

  @Operation(summary = "待审批包括子表的查询结果")
  @GetMapping("vad-approvePage-with-child")
  public R<Page<?>> vadApprovePageWithChild(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.vadApprovePageWithChildSearch(search));
  }

  @Operation(summary = "待审批最后更新时间")
  @GetMapping("vad-approveLastUpdateTime")
  public R<Date> vadApproveLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadApproveLastUpdateTime(search));
  }

  @Operation(summary = "待调整")
  @GetMapping("vad-change")
  public R<List<AdjustmentOrderItemVo>> vadChange(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadChange(search));
  }

  @Operation(summary = "待调整分页")
  @GetMapping("vad-changePage")
  public R<Page<AdjustmentOrderItemVo>> vadChangePage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadChangePage(search));
  }

  @Operation(summary = "待调整包括子表的查询结果")
  @GetMapping("vad-changePage-with-child")
  public R<Page<?>> vadChangePageWithChild(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.vadChangePageWithChildSearch(search));
  }

  @Operation(summary = "待调整最后更新时间")
  @GetMapping("vad-changeLastUpdateTime")
  public R<Date> vadChangeLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadChangeLastUpdateTime(search));
  }

  @Operation(summary = "已完成")
  @GetMapping("vad-finshed")
  public R<List<AdjustmentOrderItemVo>> vadFinshed(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadFinshed(search));
  }

  @Operation(summary = "已完成分页")
  @GetMapping("vad-finshedPage")
  public R<Page<AdjustmentOrderItemVo>> vadFinshedPage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadFinshedPage(search));
  }

  @Operation(summary = "已完成包括子表的查询结果")
  @GetMapping("vad-finshedPage-with-child")
  public R<Page<?>> vadFinshedPageWithChild(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.vadFinshedPageWithChildSearch(search));
  }

  @Operation(summary = "已完成最后更新时间")
  @GetMapping("vad-finshedLastUpdateTime")
  public R<Date> vadFinshedLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadFinshedLastUpdateTime(search));
  }

  @Operation(summary = "已撤销")
  @GetMapping("vad-revoke")
  public R<List<AdjustmentOrderItemVo>> vadRevoke(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadRevoke(search));
  }

  @Operation(summary = "已撤销分页")
  @GetMapping("vad-revokePage")
  public R<Page<AdjustmentOrderItemVo>> vadRevokePage(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadRevokePage(search));
  }

  @Operation(summary = "已撤销包括子表的查询结果")
  @GetMapping("vad-revokePage-with-child")
  public R<Page<?>> vadRevokePageWithChild(
    AdjustmentOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.vadRevokePageWithChildSearch(search));
  }

  @Operation(summary = "已撤销最后更新时间")
  @GetMapping("vad-revokeLastUpdateTime")
  public R<Date> vadRevokeLastUpdateTime(AdjustmentOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.vadRevokeLastUpdateTime(search));
  }

  @Operation(summary = "数量调整")
  @PostMapping("quantityAdjustmentPeriod")
  public R<?> quantityAdjustmentPeriod(@RequestBody JSONObject param) {
    return R.data(() -> service.quantityAdjustmentPeriod(param));
  }

  @Operation(summary = "SKU调整")
  @PostMapping("skuAdjustment")
  public R<?> skuAdjustment(@RequestBody JSONObject param) {
    return R.data(() -> service.skuAdjustment(param));
  }

  @Operation(summary = "查询可用量")
  @PostMapping("queryAvailability")
  public R<?> queryAvailability(@RequestBody JSONObject param) {
    return R.data(() -> service.queryAvailability(param));
  }

  @Operation(summary = "查询店铺")
  @PostMapping("storeLocator")
  public R<?> storeLocator(@RequestBody JSONObject param) {
    return R.data(() -> service.storeLocator(param));
  }

  @Operation(summary = "查询fnsku")
  @PostMapping("queryFnsku")
  public R<?> queryFnsku(@RequestBody JSONObject param) {
    return R.data(() -> service.queryFnsku(param));
  }

  @Operation(summary = "保存新数据")
  @PostMapping("saveNewData")
  public R<?> saveNewData(@RequestBody JSONObject param) {
    return R.data(() -> service.saveNewData(param));
  }

  @Operation(summary = "查询可用库位")
  @PostMapping("queryAvailableDatabase")
  public R<?> queryAvailableDatabase(@RequestBody JSONObject param) {
    return R.data(() -> service.queryAvailableDatabase(param));
  }

  @Operation(summary = "查询次品库位")
  @PostMapping("queryDefectiveDatabase")
  public R<?> queryDefectiveDatabase(@RequestBody JSONObject param) {
    return R.data(() -> service.queryDefectiveDatabase(param));
  }

  @Operation(summary = "查询库位数量")
  @PostMapping("queryNumberDatabase")
  public R<?> queryNumberDatabase(@RequestBody JSONObject param) {
    return R.data(() -> service.queryNumberDatabase(param));
  }

  @Operation(summary = "查询SKU")
  @PostMapping("querySku")
  public R<?> querySku(@RequestBody JSONObject param) {
    return R.data(() -> service.querySku(param));
  }

  @Operation(summary = "筛选数据 ")
  @PostMapping("DataFiltration")
  public R<Page<AdjustmentOrderDataFiltrationResult>> dataFiltration(
    AdjustmentOrderDataFiltrationParam param
  ) {
    return R.data(() -> service.dataFiltration(param));
  }
}
